<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'', styles:'bootstrap,font-awesome,animate,style,bootstrap-table,layui'}){%>
    <style type="text/css">
        body{padding-top:10px;}
        *{margin:0;padding:0;list-style-type:none;}
        a,img{border:0;}
        .demo h2{font-size:16px;color:#3366cc;height:30px;}
        .demo li{float:left;}
    </style>
    <%}%>
</head>

<body>

<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <!-- START 右侧数据 -->
            <div class="ibox float-e-margins" style="margin-bottom: 0px;">
                <div class="ibox-content" style="padding:15px 20px 0px 20px;">
                    <form id="search-form" role="form" class="form-horizontal" autocomplete="off">
                        <input type="hidden" value="${flag}" name="flag">
                        <div class="form-group">
                            <label class="control-label col-sm-1">SKU:</label>
                            <div class="col-sm-2">
                                <input type="text" id="designSku" name="designSku" placeholder="请输入SKU" class="form-control">
                            </div>
                            <label class="control-label col-sm-1">关键字:</label>
                            <div class="col-sm-2">
                                <input type="text" id="designProductName" name="designProductName" placeholder="请输入产品关键字" class="form-control">
                            </div>
                            <label class="control-label col-sm-1">渠道:</label>
                            <div class="col-sm-2">
                                <select id="designChannelId" name="designChannelId" class="form-control">
                                    <option value="">全部分类</option>
                                    <%for(var dict in channel){%>
                                    <option value="${dict.erpChannelId}">${dict.erpChannelName}</option>
                                    <%}%>
                                </select>
                                <input type="hidden" name="designChannelName" id="designChannelName">
                            </div>
                            <label class="control-label col-sm-1">活动状态:</label>
                            <div class="col-sm-2">
                                <select  name="designStatus" id="designStatus" class="form-control">
                                    <option value="">全部分类</option>
                                    <option value="1">未开始</option>
                                    <option value="2">进行中</option>
                                    <option value="3">已完成</option>
                                    <option value="4">已取消</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-1">产品名称:</label>
                            <div class="col-sm-2">
                                <input type="text" id="productName" name="productName" placeholder="产品名称" class="form-control">
                            </div>
                            <label class="control-label col-sm-1">时间类型:</label>
                            <div class="col-sm-2">
                                <select  name="timeType" id="timeType" class="form-control">
                                    <option value="">全部分类</option>
                                    <option value="1">提出时间</option>
                                    <option value="2">照片提供时间</option>
                                    <option value="3">实际完成时间</option>
                                </select>
                            </div>
                            <label class="control-label col-sm-1">开始时间:</label>
                            <div class="col-sm-2">
                                <input type="text" id="beginDate" name="beginDate" placeholder="请选择开始时间" class="form-control">
                            </div>
                            <label class="control-label col-sm-1">结束时间:</label>
                            <div class="col-sm-2">
                                <input type="text" id="endDate" name="endDate" placeholder="请选择结束时间" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-sm-1">商品属性:</label>
                            <div class="col-sm-2">
                                <select  name="designProductProperty" id="designProductProperty" class="form-control">
                                    <option value="">全部属性</option>
                                    <%for(var dict in dictFun("base_product_property", "")){%>
                                    <option value="${dict.detailCode}"  >${dict.detailName}</option>
                                    <%}%>
                                </select>
                            </div>
                            <label class="control-label col-sm-1">是否到样:</label>
                            <div class="col-sm-2">
                                <select  name="designToSample" id="designToSample" class="form-control">
                                    <option value="">全部分类</option>
                                    <option value="1">是</option>
                                    <option value="2">否</option>
                                </select>
                            </div>
                            <a class="search-btn btn btn-success" style="margin-bottom: 0px;">查询</a>
                        </div>
                    </form>
                </div>
            </div>
            <a class="export-btn btn btn-sm btn-success"><i class="glyphicon glyphicon-list-alt" aria-hidden="true"></i> 导出数据</a>

            <!-- START 操作按钮 -->
            <!-- END 操作按钮 -->

            <!-- START 数据表格 -->
            <table id="relatedTable"
                       data-toolbar="#toolbar"
                   data-side-pagination="server"
                   data-pagination="true"
                   data-resizable="true"
                   data-side-pagination="server"
                   data-url="/bbpk/cross/design/findByCnd.do?flag=${flag}"
                   data-page-size="15"
                   class="table table-striped table-hover"
                   >
            </table>
            <!-- END 数据表格 -->

            <!-- END 右侧数据 -->
        </div>
    </div>
</div>

<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,bootstrap-table,dtvalidate,dtvalidate-lang-zh_cn,bootstrap-table-zh-CN,laydate,layer'}){}%>
<script>
    var $relatedTable = $('#relatedTable'),selections=[];
    laydate.render({
        elem : '#beginDate',
        trigger : 'click'
    });
    laydate.render({
        elem : '#endDate',
        trigger : 'click'
    });
    $(function(){
        //START 表格配置
        $relatedTable.bootstrapTable({
            columns: [
                {
                    title: '渠道',
                    field: 'designChannelName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: 'SKU',
                    field: 'designSku',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '产品名称',
                    field: 'productName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '商品属性',
                    field: 'designProductProperty',
                    align: 'center',
                    valign: 'middle'

                },
                {
                    title: '简单描述要求',
                    field: 'designDescription',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '拍照数量',
                    field: 'designShootNumber',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '设计数量',
                    field: 'designNumber',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '原CTR',
                    field: 'designOldCtr',
                    align: 'center',
                    valign: 'middle'
                },
 /*               {
                    title: '现CTR',
                    field: 'designNewCtr',
                    align: 'center',
                    valign: 'middle'
                },*/
                {
                    title: '是否来样',
                    field: 'designToSample',
                    align: 'center',
                    valign: 'middle',
                    formatter:function(v,r){
                        if(v==null){
                            return '';
                        }else if(v==1){
                            return '是';
                        }else if(v==2){
                            return '否';
                        }
                        return ''
                    }
                },
                {
                    title: '预计样品到期日',
                    field: 'designSampleExpiry',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '预计上新时间',
                    field: 'designExpectNew',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '参考图',
                    field: 'designPic',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r) {
                        if(null!=v && v!=''){
                            var result='<button  class="download-sku-btn layui-btn  layui-btn-sm"  style="margin-top: -6px;margin-left: -4px">';
                            result+='<i class="fa fa-download" aria-hidden="true"></i> <a href="'+v+'" download style="color: white">下载参考图</a>';
                            result+='</button>';
                            return result;
                        }
                    }
                },
                {
                    title: '提出时间',
                    field: 'designCreate',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r) {
                        if(v==null){
                            return '';
                        }
                        if(null!=v && v.length>10){
                            v=v.substr(0,10);
                        }
                        return v;
                    }
                },
                {
                    title: '照片提供时间',
                    field: 'designExpect',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v, r) {
                        if(null==v || v==''){
                            return '<button class="complete-btn layui-btn layui-btn-normal layui-btn-sm" data-val="'+r.id+'"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> <a  style="color: white">照片提供时间</a></button>';
                        }else {
                            return v;
                        }
                    }
                },
                {
                    title: '实际完成时间',
                    field: 'designComplete',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '提出人',
                    field: 'designMember',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '完成人',
                    field: 'designCompleteName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '状态',
                    field: 'designStatus',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v, r) {
                        if(v=='1'){
                            return '未开始'
                        }else  if(v=='2'){
                            return  '进行中'
                        }else if(v=='3'){
                            return '已完成'
                        }else if(v=='4'){
                            return '已取消'
                        }else {
                            return '未知'
                        }
                    }
                },
                {
                    title: '备注',
                    field: 'designRemark',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '附件',
                    field: 'designAttachment',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r) {
                        if(null!=v && v!=''){
                            var result='<button  class="download-btn layui-btn  layui-btn-sm"  style="margin-top: -6px;margin-left: -4px">';
                            result+='<i class="fa fa-download" aria-hidden="true"></i> <a href="'+v+'" download style="color: white">下载附件</a>';
                            result+='</button>';
                            return result;
                        }else{
                            return '';
                        }
                    }
                },
                {
                    field: 'operate',
                    title: '操作',
                    align: 'center',
                    valign: 'middle',
                    formatter: optFormatter
                }
            ],
            onLoadSuccess : function(){
                $('.edit-status-btn').on('click',function () {
                    var id = $(this).attr('data-val');
                    layer.open({
                        title: false,
                        closeBtn: 0,
                        type: 2,
                        area: ['100%','100%'],
                        skin: 'layer-ext-espresso',
                        content: ['/bbpk/design/editStatus.do?id='+id, 'yes']
                    });
                });
                $('.complete-btn').on('click',function () {
                    var id = $(this).attr('data-val');
                    layer.open({
                        type: 2,
                        area: ['500px','400px'],
                        content: ['/bbpk/design/editExpect.do?id='+id, 'yes']
                    });
                });
            }
        });
        //END 表格配置
        //表格高度自适应
//        $(window).resize(function () {
//            $dealTable.bootstrapTable('resetView', {
//                height: getHeight()
//            });
//        });
    });
    //操作菜单
    function optFormatter(value,row){
        if(row.designStatus==3 || row.designStatus==4){
            return '';
        }else{
            var content = '<button class="edit-status-btn btn btn-xs btn-info" data-val="'+row.id+'" title="修改"><i class="fa fa-edit"></i>  </button>';
            return content;
        }
    }
    $('.search-btn').on('click',function(){
        var beginDate=$("#beginDate").val();
        var endDate=$("#endDate").val();
        var designStatus=$("#designStatus").val();
        if(beginDate!=''&&(endDate=='')){
            parent.layer.msg('请选择结束时间！',{icon: 0,time:1500,shade: [0.8, '#393D49']});
            return;
        }else if(beginDate==''&& endDate !=''){
            parent.layer.msg('请选择开始时间！',{icon: 0,time:1500,shade: [0.8, '#393D49']});
            return;
        }
        //检查开始和结束时间是否符合规则
        if(beginDate!=''&&endDate!=''){
            var stdt=new Date(beginDate.replace("-","/"));
            var etdt=new Date(endDate.replace("-","/"));
            if(stdt>etdt) {
                parent.layer.msg('开始时间必须小于结束时间！', {icon: 0, time: 1500, shade: [0.8, '#393D49']});
                return;
            }
        }
        $relatedTable.bootstrapTable('refresh', { url:'${ctxPath}/bbpk/cross/design/findByCnd.do?'+$('#search-form').serialize() });
    });
    $(".export-btn").click(function () {
        window.location.href='/bbpk/design/export.do?'+$('#search-form').serialize();
    });
</script>
</body>
</html>
